home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / pxm_ray / pxm_ray.lha / pxm-ray / pixel_rnd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-09  |  289 b   |  34 lines

  1.  
  2. /*
  3.  * pretty decent random number generator
  4.  */
  5.  
  6.  
  7.  
  8. #include    "pxm.h"
  9.  
  10. double    _seed;
  11.  
  12. double    rnd()
  13. {
  14.     double alpha = 1027;
  15.  
  16.     _seed *= alpha;
  17.     _seed = (unsigned long int)_seed % 8388607;
  18.  
  19.     return _seed/8388607;
  20. }
  21.  
  22. double    rand()
  23. {
  24.     return (rnd()*2 - .5);
  25. }
  26.  
  27.  
  28. srand(s)
  29. int    s;
  30. {
  31.     _seed = s;
  32. }
  33.  
  34.